#include "bsp_g3507std.h"
#include "ti_msp_dl_config.h"
#include "user_main.h"


uint32_t g_g3507_board_order_array[G3507_BOARD_ORDER_ARRAY_LEN];
uint32_t g_g3507_board_sensor_array[G3507_BOARD_SENSOR_ARRAY_LEN];

////////////////////////////////////
////////////////////////////////////
void bsp_user_led_flashing(uint8_t led_mode, uint8_t led_pwm_duty)
{
    if(led_mode == NORMAL_CLOSE) //常灭
        DL_TimerG_setCaptureCompareValue(PWM_0_INST, 0, GPIO_PWM_0_C0_IDX);
    else if(led_mode == NORMAL_OPEN) //常亮
        DL_TimerG_setCaptureCompareValue(PWM_0_INST, 10 * led_pwm_duty, GPIO_PWM_0_C0_IDX);
    else if(led_mode == SLOW_FLASHING) //慢闪
    {
        if(g_ticks_inc % 1000 < 500)
            DL_TimerG_setCaptureCompareValue(PWM_0_INST, 10 * led_pwm_duty, GPIO_PWM_0_C0_IDX);
        else
            DL_TimerG_setCaptureCompareValue(PWM_0_INST, 0, GPIO_PWM_0_C0_IDX);
    }
    else if(led_mode == FAST_FLASHING) //快闪
    {
        if(g_ticks_inc / 200 % 2)
            DL_TimerG_setCaptureCompareValue(PWM_0_INST, 10 * led_pwm_duty, GPIO_PWM_0_C0_IDX);
        else
            DL_TimerG_setCaptureCompareValue(PWM_0_INST, 0, GPIO_PWM_0_C0_IDX);
    }
}

int g3507_board_get_sensor( uint32_t *board_sensor_array , uint32_t board_sensor_array_len  )
{

    return 0;
}

int g3507_board_set_order( uint32_t *board_order_array  , uint32_t board_order_array_len  )
{
    bsp_user_led_flashing(board_order_array[0], board_order_array[1]);
    return 0;
}
